require(["config"], function(config) {
	require(["jquery.ui", "com", "jquery", "zepto", "sw", "toast"], function(jqui, com, jq, zep, sw, t) {
		console.log( document.body.scrollTop);
		jq("#jion2").mousemove(function(){
			jq(".rightcd").css("display","block");	
		});
		jq("#jion2").mouseout(function(){
			jq(".rightcd").css("display","none");
		});
		jq.ajax({
			type:"get",
			url:"js/sy/sy.json",
			success:function(obj){
				for(var i=0;i<obj.length;i++){
					jq("<div class='rightcd'><div class='righttop'></div><div class='rightbottom'></div></div>").appendTo(jq("#jion2")).eq(i);
					jq('<h4>'+obj[i].np[0].eccaidan1+'</h4>').appendTo(jq(".rightcd .righttop").eq(i));
					jq('<h4>'+obj[i].np[1].eccaidan1+'</h4>').appendTo(jq(".rightcd .rightbottom").eq(i));
					
					for(var j=0;j<obj[i].np[0].eccaidan2.length;j++){
						jq('<a href="#">'+obj[i].np[0].eccaidan2[j]+'</a>').appendTo(jq(".righttop").eq(i));
						jq('<a href="#">'+obj[i].np[1].eccaidan2[j]+'</a>').appendTo(jq(".rightbottom").eq(i));
					};					
				};
				jq("#jion2 li").hover(function(){
					jq(".rightcd").eq(jq(this).index()).show();
					console.log(jq(this).index());				
				},function(){
					jq(".rightcd").eq(jq(this).index()).hide();
				});			
			}
		});
	jq("#dlxx").hover(function(){
			jq(".dlxx").show();
		},function(){
			jq(".dlxx").hide();
		})
		jq("#dhgwc").hover(function(){
			jq(".dhgwc").show();
		},function(){
			jq(".dhgwc").hide();
		})
		 jq("#dlzd").click(function(e){
            e.preventDefault();
            $(document.documentElement).animate({
                scrollTop: 0
                },1000);
            //支持chrome
            $(document.body).animate({
                scrollTop: 0
                },1000);
        });
        (function(){
        	for(var i=0;i<jq("#cr_top li").length;i++){
        		jq("#cr_top li").on("click",function(){
        			jq(this).css("background","#fff").siblings().css("background","#999");
        			var num = jq(this).index();
        			jq("#cr_bottom div").eq(num).css("display","block").siblings().css("display","");
        		})
        	}	
        }());        
        
        
        (function(){
        	jq("#clss").on("click",function(){
        		jq("#jrwch").css("display","none");
        	});
        	jq("#spjx").on("click",function(){
        		jq("#jrwch").css("display","none");
        	});
        }())
      jq("#ljjs").on("click",function(){
      	window.location.href="http://127.0.0.1/qebody/gwc.html";
      })
      var spmun =com.setCookie("spnumber");
        (function(){
        	var num=0;
        	jq("#gwdj").on("click",function(){
      			num++;     			
      			jq("#ghwnum").text("("+num+")");
      			jq("#num").text(num);
      			if(num>=1){
      				jq(".dhgwc").text("请点击结算");
      			};
      			jq("#jrwch").css("display","block");
      			var mnum = jq("#spjg").text();
      			var gnum = jq("#jsnum").val();
      			var spname = jq("#spname").text();
      			jq("#sp_num").text(gnum);   			
      			jq("#sp_rmb").text(mnum*gnum ); 
      			com.setCookie("spnumber",gnum, 10);
      			var newspnum=parseInt(com.getCookie("spnumber"))+parseInt(gnum);
   			   console.log(newspnum);
    			com.setCookie("spname", spname, 10);
				com.setCookie("spmony",mnum, 10);
				
				 
      	}) 
        }());
        (function(){
        	
        	if(com.getCookie("newusername")){	
        		jq("<span>"+com.getCookie("newusername")+"</span><span id='djtc' style='margin:0 5px'>[退出]<span>").appendTo(jq("#usename"));
        		jq("#usename a").css("display","none");
        	}
        	jq('#djtc').on("click",function(){
        		jq('#usename span').css("display","none");
        		jq("#usename a").css("display","block");
        	})
        }())
        	
        	
	})
 })